---每累积损失生命[0]% 清除主动技能cd
---@class BuffEffect800005100:BaseBuffEffect
BuffEffect800005100 = ClientFight.CreateClass("BuffEffect800005100",ClientFight.BaseBuffEffect)
local t = BuffEffect800005100
t.BUFF_EFFECT_70_COUNT_COST_HP = "BUFF_EFFECT_70_COUNT_COST_HP_"
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...}
    local target = buff.target
    if (#parameters < 3) then
        return IBuffEffect.FAIL;
    end

    local result = parameters[3];
    if (result:isDamage()) then
        return IBuffEffect.FAIL;
    end
    if (not AttackUtils.isDamage(result:getState())) then
        return IBuffEffect.FAIL;
    end
    local buffEffectValue = buff.buffBean.f_BuffEffectValue

    local maxHp = FighterAttributeManager.getFightAttr(target, FighterAttributeEnum.HP);
    local damage = result:getDamage();
    local currPer = math.floor(damage / maxHp * Global.TEN_THOUSANDTH);

    --已累积损失生命
    local costHpPer = math.floor(buff.effectParams[t.BUFF_EFFECT_70_COUNT_COST_HP]) or 0
    costHpPer =costHpPer + currPer;
    buff.effectParams[t.BUFF_EFFECT_70_COUNT_COST_HP] = costHpPer--//累计减血%% 存储下来

    local triggerNum = costHpPer / buffEffectValue[1];
    if (triggerNum < 1)  then--//累积的值不够触发一次的
        return IBuffEffect.FAIL;
    end
    costHpPer = costHpPer - triggerNum * buffEffectValue[1]--//剩余能量
    buff.effectParams[t.BUFF_EFFECT_70_COUNT_COST_HP] = costHpPer

    --达成条件, 触发清空技能CD ,
    local entries = target.cooldowns
    for skillId, entry in pairs( entries) do
        local skillBean = SkillManager.getSkillBean(skillId,nil);
        local continue = false
        if (skillBean == nil) then
            continue = true;
        end
        if not continue then
            if (skillBean.f_TriggerType == SkillActionTypeEnum.ACTIVE or
                    skillBean.f_TriggerType == SkillActionTypeEnum.TRIGGER) then
                if (entry.delay * Global.FIGHT_FRAME < 30000) then --//策划说加个保险, 超过30秒的技能,不清CD
                    entry.delay = 0
                end
            end
        end
    end
    SkillRoleMgr.savePathFile( "[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
    ..buff.modelId .. " 触发每累积损失生命" ..buffEffectValue[1]+" %% 清空主动技能CD");
    return ClientFight.BaseBuffEffect.action(self,fight, buff, ...);
end
t.New()